package com.example.shop.domain;


import com.example.shop.bos.BaseEntity;
import com.example.shop.bos.BosSet;
import com.example.shop.bos.Bostype;
import lombok.Data;

import javax.persistence.*;
import java.math.BigDecimal;
import java.util.HashSet;
import java.util.Set;

@Entity
@Bostype("A02")
@Table(name = "T_ORDER")
@Data
public class Order extends BaseEntity {

    private String name;

    private String phone;

    private String address;

    private String openId;

    private BigDecimal amount;

    private Integer order_status;

    private Integer pay_status;

    @OneToMany(cascade = CascadeType.ALL, mappedBy = "parent", orphanRemoval = true, fetch = FetchType.EAGER)
    private Set<OrderItem> orderitems = new HashSet<>();

    public BosSet<OrderItem> getItems() {
        return new BosSet(this.orderitems, this);
    }
}
